<?php
/*
 * @ https://EasyToYou.eu - IonCube v11 Decoder Online
 * @ PHP 7.2 & 7.3
 * @ Decoder version: 1.1.6
 * @ Release: 10/08/2022
 */

// Decoded file for php version 71.
namespace app\adapay\model;

class Record extends \app\BaseModel
{
    protected $name = "shequshop_adapay_record";
    public function dataAdd($data)
    {
        $res = $this->insert($data);
        return $res;
    }
    public function dataUpdate($dis, $data)
    {
        $res = $this->where($dis)->update($data);
        return $res;
    }
    public function dataList($dis, $page)
    {
        $data = $this->where($dis)->order("status desc,id desc")->paginate($page)->toArray();
        return $data;
    }
    public function dataInfo($dis)
    {
        $data = $this->where($dis)->find();
        return !empty($data) ? $data->toArray() : [];
    }
    public function updateOne($id)
    {
        $user_id = $this->where(["id" => $id])->value("user_id");
        $res = $this->where(["user_id" => $user_id])->where("id", "<>", $id)->update(["status" => 0]);
        return $res;
    }
    public function addRecord($order, $commission, $id)
    {
        $order["top_order_id"] = !empty($order["top_order_id"]) ? $order["top_order_id"] : $order["order_id"];
        $insert = ["uniacid" => $order["uniacid"], "order_id" => $order["top_order_id"], "commission_id" => $commission["id"], "cash" => $commission["cash"], "type" => $commission["type"], "adapay_id" => $id, "son_order_id" => $order["top_order_id"] == $order["order_id"] ? 0 : $order["order_id"]];
        $res = $this->dataAdd($insert);
        return $res;
    }
}

?>